﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FernUniHagen.CompilerExtension.DataStructures
{
    public static class VariableCreatorService
    {
        private static string _tempVariableName = "roslynVariable";
        private static string _definitionVariableName = "roslynDefinition";
        private static int _tempVariableNumber = 0;
        private static int _definitionVariableNumber = 0;


        /// <summary>
        /// Returns a helper variable for the translation of an expression
        /// </summary>
        /// <returns></returns>
        public static string GetTempVariable()
        {
            _tempVariableNumber++;
            return GetVariableName(_tempVariableName, _tempVariableNumber);

        }

        /// <summary>
        /// Returns a new name for the definition. For better readability the new name is based on the original variable name
        /// </summary>
        /// <returns></returns>
        public static string GetDefinitionVariable(string originalName)
        {
            _definitionVariableNumber++;
            return GetVariableName( originalName + "_" + _definitionVariableName, _definitionVariableNumber);

        }

        /// <summary>
        /// Creates a new variable name based on the provided input
        /// </summary>
        /// <param name="variableName"></param>
        /// <param name="number"></param>
        /// <returns></returns>
        private static string GetVariableName(string variableName, int number)
        {
            string uniqueVariableName = string.Format("{0}{1}", variableName, number);
            return uniqueVariableName;
        }

       
    }
}
